﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAO;
using QLDHS;



 
namespace QLDHS
{
    public partial class Login : Form
    {
        int kt;

        public int Kt
        {
            get { return kt; }
            set { kt = value; }
        }


        public Login()
        {
            InitializeComponent();
            
        }

        private void bt_login_Click(object sender, EventArgs e)
        {
           
            if (Login_DAO.LoadUser(txt_login_user.Text.ToString(),txt_login_pass.Text.ToString())==2)
            {
                kt = 1;
                
                MessageBox.Show("Login Sucessfull.Click OK to continue", "Wellcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FrmMain t = new FrmMain();
                MessageBox.Show("okkk");
              
                this.Close();
               
            }
            else if (Login_DAO.LoadUser(txt_login_user.Text.ToString(), txt_login_pass.Text.ToString()) == 1)
            {
                MessageBox.Show("Hi administrator....!", "Wellcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FrmMain t = new FrmMain();
                
                this.Close();
                
                kt = 2;
            }
            else
            {
                MessageBox.Show("Wrong Username/Password! \n Please try again!", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_login_user.Text = "";
                txt_login_pass.Text = "";
            }
        }

        private void cb_login_sp_CheckedChanged(object sender, EventArgs e)
        {
            txt_login_pass.PasswordChar = '*';
            if (cb_login_sp.Checked)
                txt_login_pass.PasswordChar = (char)0;


        }



        private void bt_login_quit_Click(object sender, EventArgs e)
        {
            DialogResult h = MessageBox.Show("Bạn có thật sự muốn thoát khỏi chương trình  ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            if (h == DialogResult.Yes)
            {
                Application.Exit();
            }
        }
       
    }
}
